﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;

namespace T.FAS.Runtime.Metadata.Entity.DataModel
{
    /// <summary>
    /// 实体对象
    /// </summary>
    [Serializable]
    public partial class EntityObject : AbsMetaDataContent,System.ICloneable
    {
        /// <summary>
        /// 主键id
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 数据查询标识
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 数据查询名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 租户id
        /// </summary>  
        [JsonIgnore]
        public string TenantID { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>  
        [JsonIgnore]
        public string Ext1 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>  
        [JsonIgnore]
        public string Ext2 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>  
        [JsonIgnore]
        public string Ext3 { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        //[DataMember]
        public override string Creator { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>        
        //[DataMember]
        public override DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        //[DataMember]
        public override string LastModifier { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>        
        //[DataMember]
        public override DateTime LastModifyTime { get; set; }

        /// <summary>
        /// 实体对象属性集合
        /// </summary>
        public List<EntityObjectAttribute> EntityObjectAttributes { get; set; } = new List<EntityObjectAttribute>();

        public override object Clone()
        {
            var entity = this.MemberwiseClone() as EntityObject;

            if (EntityObjectAttributes != null)
            {
                entity.EntityObjectAttributes = new List<EntityObjectAttribute>();
                this.EntityObjectAttributes.ForEach(x => entity.EntityObjectAttributes.Add(x.Clone() as EntityObjectAttribute));
            }

            return entity;
        }
    }
}
